package com.linsir.auth.dto;

/*
import com.linsir.cloud.saas.api.dto.auth.UserDto;
*/
import jakarta.annotation.Resource;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * @ClassName : PassWordUserDetails
 * @Description :
 * @Author : Linsir
 * @Date: 2023-12-27 04:53
 */
@Data
public class OAuth2DetailsDto implements UserDetails {

    private String userName;

    private String password;

    private List<OAuth2GrantedAuthorityDto> oAuth2GrantedAuthorityDtoList;



    public  OAuth2DetailsDto ()
    {

    }

   /* public  OAuth2DetailsDto (UserDto userDto)
    {

    }*/

    public void getMemoryDetails()
    {
        this.userName = "admin";

        PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();



        this.password = passwordEncoder.encode("123456");
        OAuth2GrantedAuthorityDto oAuth2GrantedAuthorityDto = new OAuth2GrantedAuthorityDto();
        oAuth2GrantedAuthorityDto.setAuthority("/app");
        this.oAuth2GrantedAuthorityDtoList = new ArrayList<>();
        this.oAuth2GrantedAuthorityDtoList.add(oAuth2GrantedAuthorityDto);
    }


    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return this.oAuth2GrantedAuthorityDtoList;
    }

    @Override
    public String getPassword() {
        return this.password;
    }

    @Override
    public String getUsername() {
        return this.userName;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
